//
//  YJMoreinformationController.m
//  SnackCourier
//
//  Created by qianfeng01 on 15/7/21.
//  Copyright (c) 2015年 qianfeng01. All rights reserved.
//

#import "YJMoreinformationController.h"
#import "AFNetworking.h"
#import "UIImageView+WebCache.h"


@interface YJMoreinformationController ()

@property (nonatomic,strong)UIScrollView *scrollerView;

@property (nonatomic,strong)AFHTTPRequestOperationManager *manager;

@end

@implementation YJMoreinformationController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)initData{
    self.scrollerView =[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-64-49)];
    self.manager=[AFHTTPRequestOperationManager manager];
    self.manager.responseSerializer =[AFHTTPResponseSerializer serializer];
    __weak typeof (self)weakSelf=self;
    [self.manager GET:self.urlStr parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {

        if (responseObject) {
            
            NSDictionary *dicts =[NSJSONSerialization JSONObjectWithData:responseObject options:(NSJSONReadingMutableContainers) error:nil];
            NSDictionary *data=dicts[@"data"];
            NSArray *array =data[@"description"];
            
            self.scrollerView.contentSize =CGSizeMake(self.view.frame.size.width, (self.view.frame.size.height)*array.count);
            self.scrollerView.userInteractionEnabled =YES;
            self.scrollerView.bounces =NO;
            self.scrollerView.alwaysBounceHorizontal =NO;
            self.scrollerView.showsVerticalScrollIndicator =NO;
            int i=0;
            for (NSDictionary *dict in array) {
                

                UIImageView *imageView =[[UIImageView alloc] initWithFrame:CGRectMake(0, i*weakSelf.view.frame.size.height, weakSelf.view.frame.size.width, weakSelf.view.frame.size.height)];
               // imageView.contentMode=UIViewContentModeScaleToFill;
                [imageView sd_setImageWithURL:[NSURL URLWithString:dict[@"picUrl"]]];

                [self.scrollerView addSubview:imageView];
                i++;
            }
            [self.view addSubview:self.scrollerView];
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
    }];
}


@end
